import time
from selenium import webdriver
from selenium.webdriver.common.by import By
from selenium.webdriver import ActionChains


drives = webdriver.Chrome('../../chrom/chromedriver.exe')

drives.get('https://news.sina.com.cn/')

action = ActionChains(drives)

button_title = drives.find_element(By.CLASS_NAME, 'ptn_13').click()
time.sleep(2)

button_href = drives.find_element(By.XPATH, '//*[@id="tech_head"]/div[7]/div/a')
action.move_to_element(button_href)

button_href = drives.find_element(By.XPATH, '//*[@id="tech_head"]/div[7]/div/ul/li[1]/a')

action.click()
action.perform()

print(drives.window_handles)
print(drives.current_window_handle)

drives.switch_to.window(drives.current_window_handle)
drives.close()

drives.switch_to.window(drives.window_handles[0])
drives.close()

time.sleep(6)
drives.quit()
